Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relax][Bugfix] Bind symbolic variables in R.match_cast #17023

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, variable replacement by BindSymbolicVars would fail to replace variables that occur within a relax::MatchCast node. This pattern is rare, because the bind_symbolic_vars method can only replace variables that are exposed as part of the function signature, and most uses of relax::MatchCast act as a definition for symbolic variables that are not exposed through the function signature. This pattern is well-formed, though, since the relax::MatchCast node can also act as a user of previously-defined symbolic variables.

The root cause for this bug was in the ExprMutator visitor for relax::MatchCast, which did not visit the struct info field. As a result, the virtual ExprMutator::VisitPrimExpr function was not called for expressions that occur within the StructInfo of a relax::MatchCast. This commit updates ExprMutator to resolve this bug, and applies an analogous fix for ExprVisitor.

Prior to this commit, variable replacement by `BindSymbolicVars` would
fail to replace variables that occur within a `relax::MatchCast` node.
This pattern is rare, because the `bind_symbolic_vars` method can only
replace variables that are exposed as part of the function signature,
and most uses of `relax::MatchCast` act as a definition for symbolic
variables that are not exposed through the function signature.  This
pattern is well-formed, though, since the `relax::MatchCast` node can
also act as a user of previously-defined symbolic variables.

The root cause for this bug was in the `ExprMutator` visitor for
`relax::MatchCast`, which did not visit the struct info field.  As a
result, the virtual `ExprMutator::VisitPrimExpr` function was not
called for expressions that occur within the `StructInfo` of a
`relax::MatchCast`.  This commit updates `ExprMutator` to resolve this
bug, and applies an analogous fix for `ExprVisitor`.

Co-authored-by: Chris Sullivan <csullivan@octoml.ai>
@Lunderberg
Copy link
Contributor Author

Closing to resubmit as a new PR (same issue as mentioned here), due to CI issues.

@Lunderberg Lunderberg closed this May 28, 2024
@Lunderberg Lunderberg deleted the relax_bugfix_bind_symbolic_vars_in_match_cast branch May 29, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants